package com.nacrtstudio.webgiftshop.pages;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.nacrtstudio.webgiftshop.facade.Controller;
import com.nacrtstudio.webgiftshop.model.shop.User;

public class ChangeData {
	@Inject
	private Controller controller;
	
	@Property
	private User user;

	
	private void onActivate() {
		try {
			user = controller.getLoggedUser();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	public boolean isLoggedIn(){
		return controller.isLoggedIn();
	}
	
	Object onSuccess(){
		controller.updateUser(user);
		return UserProfile.class;
	}
}
